<?php
// $Id: TextAreaInput.php 27 2010-11-16 12:49:54Z mjohnson60@gmail.com $


/**
 * Enter description here ...
 * 
 * @author markjohnson
 * @version 1.0
 * @copyright Copyright (c) 2010, markjohnson
 * @license http://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
 *
 */
class TextAreaInput extends FormElement
{
	/**
	 * Enter description here ...
	 * 
	 * @var unknown_type
	 */
	var $rows = 5;
	
	/**
	 * Enter description here ...
	 * 
	 * @var unknown_type
	 */
	var $cols = 60;

	/**
	 * Enter description here ...
	 * 
	 * @param string $name
	 * @param string $value
	 * @param string $id
	 * @param FormElement $parent
	 * @param array $attributes
	 * @param int $rows
	 * @param int $cols
	 */
	function __construct($name, $value = NULL, $id = NULL, $parent = NULL, $attributes = array(), $rows = 5, $cols = 60)
	{
		$this->type = 'textarea';
		$this->rows = $rows;
		$this->cols = $cols;
		
		if (is_array($value))
		{
			parent::__construct($value, $name);
		}
		else
		{
			parent::__construct(NULL, $name, $value, $id, $parent, $attributes);
		}
	}

	/* 
	 * @see FormElement::_compile()
	 */
	public function _compile()
	{
		return $this->render();
	}

	/* 
	 * @see FormElement::render()
	 */
	public function render()
	{
		$this->addHtmlClasses(array(
			'form-textarea'
		));
		
		return parent::render('<textarea cols="' . $this->cols . '" rows="' . $this->rows . '" name="' . $this->name . '" id="' . $this->id . '" ' . (empty($this->attributes) ? '' : attributes($this->attributes)) . '>' . (empty($this->value) ? '' : check_plain($this->value)) . "</textarea>\n");
	}
}
